//
//  HHNavigationViewSample.swift
//  HHSwiftuiPractice
//
//  Created by YL-Hong on 2023/10/7.
//

import SwiftUI

struct HHNavigationViewSample: View {
    var body: some View {
        
        NavigationView {
            NavigationLink("HELLO", destination: SecondView())
                .navigationBarTitle("Main", displayMode: .large)
            
        }
        
        
    }
}

struct HHNavigationViewSample_Previews: PreviewProvider {
    static var previews: some View {
        HHNavigationViewSample()
    }
}

struct SecondView: View {
        
    @Environment(\.presentationMode) var presentationMode: Binding<PresentationMode>
    
//    @Environment(\.dismiss) var dismiss
    
    var body: some View {
        ZStack {
            Color.mint
                .edgesIgnoringSafeArea(.all)
                .navigationTitle("Second View")
                .navigationBarHidden(true)
            
            VStack {
                Button("BACK") {
                    presentationMode.wrappedValue.dismiss()
//                    dismiss()
                }
                
                NavigationLink("Click", destination: Text("Three screen"))
            }
        }
        .foregroundStyle(Color.black)
    }
}

